<!DOCTYPE html>
<html>
<head>
   <link href="build/classic/theme-classic/resources/theme-classic-all.css" rel="stylesheet" />
   <script type="text/javascript" src="build/ext-all.js"></script>
   <script type="text/javascript">

      Ext.define("User",{
        extend:'Ext.data.Model',
        fields:[
          {name:'id',type:'int'}
          ,{name:'name',type:'string'}
          ,{name:'age',type:'int'}
          ,{name:'marks',type:'int'}
        ]
        ,proxy:{
          url:'http://localhost:3000/users'
          ,type:'rest'
        }
      });

       Ext.onReady(function () {
         var btn=Ext.get("btn");
          btn.on("click",function(){

            //============加载=============================
            // User.load(3,{success:function(d){
            //   alert(d.getData().name);
            // }});
            //=============删除============================
            // var u=Ext.create('User',{id:1});
            // u.erase();

            //==============添加============================
            // var u=Ext.create('User',{name:'Tian',age:21,marks:12});
            // u.set("id",null);
            // u.save({
            //   success:function(x){
            //     alert(x.get("id"));
            //   }
            // });
            //=========更新============================
            // var u=Ext.create('User',{id:13});
            // u.set("name","tian123");
            // u.set("age",12);
            // u.set("marks",23);
            // u.save({
            //   success:function(x){
            //     alert(x.get("id"));
            //   }
            // });

          })
      });
   </script>
</head>
<body>
   <button id="btn">test</button>
</body>
</html>